#include <Precomp.h>
#include <Packet.h>
#include <WinSock.h>

#define DEFINE_SERVER_PACKET(x) { sizeof(x), x::FromNetworkByteOrder, #x }
#define DEFINE_SHORT_SERVER_PACKET() { -1, NULL, "" }


struct Invalid
{   
    static void FromNetworkByteOrder(BYTE*) { }
    static void ToNetworkByteOrder(BYTE*) { }
};

struct ServerPacket
{
    int     size;
    void    (*FromNetworkByteOrder) (BYTE*);
    const char* szStructureName;
};

struct ServerPacket ServerPacketHandlers[] =
{    
    DEFINE_SERVER_PACKET(Invalid),                                // EServerPacketType_None
    DEFINE_SERVER_PACKET(mesg_spacket),                           // EServerPacketType_Message,
    DEFINE_SERVER_PACKET(plyr_info_spacket),                      // EServerPacketType_PlayerInfo,
    DEFINE_SERVER_PACKET(kills_spacket),                          // EServerPacketType_PlayerKills,
    DEFINE_SERVER_PACKET(player_spacket),                         // EServerPacketType_PlayerLocation,
    DEFINE_SERVER_PACKET(torp_info_spacket),                      // EServerPacketType_TorpStatus,
    DEFINE_SERVER_PACKET(torp_spacket),                           // EServerPacketType_TorpLocation
    DEFINE_SERVER_PACKET(phaser_spacket),                         // EServerPacketType_Phaser,
    DEFINE_SERVER_PACKET(plasma_info_spacket),                    // EServerPacketType_PlasmaStatus,
    DEFINE_SERVER_PACKET(plasma_spacket),                         // EServerPacketType_PlasmaLocation,
    DEFINE_SERVER_PACKET(warning_spacket),                        // EServerPacketType_Warning,
    DEFINE_SERVER_PACKET(motd_spacket),                           // EServerPacketType_MOTD,
    DEFINE_SERVER_PACKET(you_spacket),                            // EServerPacketType_You,
    DEFINE_SERVER_PACKET(queue_spacket),                          // EServerPacketType_QueueLocation,
    DEFINE_SERVER_PACKET(status_spacket),                         // EServerPacketType_GalaxyStatus,
    DEFINE_SERVER_PACKET(planet_spacket),                         // EServerPacketType_PlanetResourceInfo,
    DEFINE_SERVER_PACKET(pickok_spacket),                         // EServerPacketType_TeamAndShipPickAccepted,
    DEFINE_SERVER_PACKET(login_spacket),                          // EServerPacketType_Login,
    DEFINE_SERVER_PACKET(flags_spacket),                          // EServerPacketType_PlayerFlags,
    DEFINE_SERVER_PACKET(mask_spacket),                           // EServerPacketType_TournamentModeMask,
    DEFINE_SERVER_PACKET(pstatus_spacket),                        // EServerPacketType_PlayerStatus,
    DEFINE_SERVER_PACKET(badversion_spacket),                     // EServerPacketType_BadVersion,
    DEFINE_SERVER_PACKET(hostile_spacket),                        // EServerPacketType_PlayerHostilitySettings,
    DEFINE_SERVER_PACKET(stats_spacket),                          // EServerPacketType_PlayerStats,
    DEFINE_SERVER_PACKET(plyr_login_spacket),                     // EServerPacketType_NewPlayerLogin,
    DEFINE_SERVER_PACKET(reserved_spacket),                       // EServerPacketType_Reserved,
    DEFINE_SERVER_PACKET(planet_loc_spacket),                     // EServerPacketType_PlanetNameAndLocation,
    DEFINE_SERVER_PACKET(Invalid),                                // EServerPacketType_Scan, // NOT IMPLEMENTED
    DEFINE_SERVER_PACKET(udp_reply_spacket),                      // EServerPacketType_UDPReply,
    DEFINE_SERVER_PACKET(sequence_spacket),                       // EServerPacketType_Sequence,
    DEFINE_SERVER_PACKET(sc_sequence_spacket),                    // EServerPacketType_SemiCriticalSequence,
    DEFINE_SERVER_PACKET(rsa_key_spacket),                        // EServerPacketType_RSA_Key,
    DEFINE_SERVER_PACKET(Invalid),                                // EServerPacketType_Invalid_31,
    DEFINE_SERVER_PACKET(Invalid),                                // EServerPacketType_Invalid_32,
    DEFINE_SERVER_PACKET(Invalid),                                // EServerPacketType_Invalid_33,
    DEFINE_SERVER_PACKET(Invalid),                                // EServerPacketType_Invalid_34,
    DEFINE_SERVER_PACKET(Invalid),                                // EServerPacketType_Invalid_35,
    DEFINE_SERVER_PACKET(Invalid),                                // EServerPacketType_Invalid_36,
    DEFINE_SERVER_PACKET(Invalid),                                // EServerPacketType_Invalid_37,
    DEFINE_SERVER_PACKET(Invalid),                                // EServerPacketType_Invalid_38,
    DEFINE_SERVER_PACKET(ship_cap_spacket),                       // EServerPacketType_ShipCapabilities,
    DEFINE_SERVER_PACKET(shortreply_spacket),                     // EServerPacketType_Short_SendShortRequestReply,
    DEFINE_SHORT_SERVER_PACKET(),                                 // EServerPacketType_Short_Message,
    DEFINE_SHORT_SERVER_PACKET(),                                 // EServerPacketType_Short_Warning,
    DEFINE_SHORT_SERVER_PACKET(),                                 // EServerPacketType_Short_You,
    DEFINE_SHORT_SERVER_PACKET(),                                 // EServerPacketType_Short_You_ShipStatus,
    DEFINE_SHORT_SERVER_PACKET(),                                 // EServerPacketType_Short_Player,
    DEFINE_SERVER_PACKET(ping_spacket),                           // EServerPacketType_Ping,
    DEFINE_SHORT_SERVER_PACKET(),                                 // EServerPacketType_Short_TorpLocation,
    DEFINE_SHORT_SERVER_PACKET(),                                 // EServerPacketType_Short_TorpStatus,
    DEFINE_SHORT_SERVER_PACKET(),                                 // EServerPacketType_Short_TorpLocationOptimized,
    DEFINE_SHORT_SERVER_PACKET(),                                 // EServerPacketType_Short_PlanetResources,
    DEFINE_SERVER_PACKET(Invalid),                                // EServerPacketType_Invalid_51,
    DEFINE_SERVER_PACKET(Invalid),                                // EServerPacketType_Invalid_52,
    DEFINE_SERVER_PACKET(Invalid),                                // EServerPacketType_Invalid_53,
    DEFINE_SERVER_PACKET(Invalid),                                // EServerPacketType_Invalid_54,
    DEFINE_SERVER_PACKET(Invalid),                                // EServerPacketType_Invalid_55,
    DEFINE_SHORT_SERVER_PACKET(),                                 // EServerPacketType_Short_Sequence,
    DEFINE_SHORT_SERVER_PACKET(),                                 // EServerPacketType_Short_Phaser,
    DEFINE_SHORT_SERVER_PACKET(),                                 // EServerPacketType_Short_PlayerKills,
    DEFINE_SHORT_SERVER_PACKET(),                                 // EServerPacketType_Short_PlayerStats,
    DEFINE_SERVER_PACKET(feature_cpacket),                        // EServerPacketType_Feature, 
};

int CPacket::GetServerPacketLen(EServerPacketType ePacketType)
{
    return ServerPacketHandlers[ePacketType].size;
}

void CPacket::FromNetworkByteOrder(packet_base* pPacket)
{
    ServerPacketHandlers[pPacket->type].FromNetworkByteOrder((BYTE*) pPacket);
}

const char* CPacket::GetPacketName(EServerPacketType ePacketType)
{
    return ServerPacketHandlers[ePacketType].szStructureName;
}


void mesg_spacket::FromNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void plyr_info_spacket::FromNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void plyr_login_spacket::FromNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void hostile_spacket::FromNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 

void stats_spacket::FromNetworkByteOrder(BYTE* pb)
{
    stats_spacket* pPacket = (stats_spacket*)pb;

    pPacket->tkills = ntohl(pPacket->tkills);
    pPacket->tlosses = ntohl(pPacket->tlosses);
    pPacket->kills = ntohl(pPacket->kills);
    pPacket->losses = ntohl(pPacket->losses);
    pPacket->tticks = ntohl(pPacket->tticks);

    pPacket->tplanets = ntohl(pPacket->tplanets);
    pPacket->tarmies = ntohl(pPacket->tarmies);
    pPacket->sbkills = ntohl(pPacket->sbkills);
    pPacket->sblosses = ntohl(pPacket->sblosses);
    pPacket->armies = ntohl(pPacket->armies);
    pPacket->planets = ntohl(pPacket->planets);
    pPacket->maxkills = ntohl(pPacket->maxkills);

}

void flags_spacket::FromNetworkByteOrder(BYTE* pb)
{
    flags_spacket* pPacket = (flags_spacket*)pb;

    pPacket->flags = ntohl(pPacket->flags);        
}


void kills_spacket::FromNetworkByteOrder(BYTE* pb)
{
    kills_spacket* pPacket = (kills_spacket*)pb;

    pPacket->kills = ntohl(pPacket->kills);
}

void player_spacket::FromNetworkByteOrder(BYTE* pb)
{
    player_spacket* pPacket = (player_spacket*)pb;

    pPacket->x = ntohl(pPacket->x);
    pPacket->y = ntohl(pPacket->y);
}

void torp_info_spacket::FromNetworkByteOrder(BYTE* pb)
{
    torp_info_spacket* pPacket = (torp_info_spacket*)pb;

    pPacket->tnum = ntohs(pPacket->tnum);
}

void torp_spacket::FromNetworkByteOrder(BYTE* pb)
{
    torp_spacket* pPacket = (torp_spacket*)pb;

    pPacket->tnum = ntohs(pPacket->tnum);
    pPacket->x = ntohl(pPacket->x);
    pPacket->y = ntohl(pPacket->y);
}

void phaser_spacket::FromNetworkByteOrder(BYTE* pb)
{
    phaser_spacket* pPacket = (phaser_spacket*)pb;

    pPacket->x = ntohl(pPacket->x);
    pPacket->y = ntohl(pPacket->y);
    pPacket->target = ntohl(pPacket->target);
}

void you_spacket::FromNetworkByteOrder(BYTE* pb)
{
    you_spacket* pPacket = (you_spacket *) pb;

    pPacket->flags = ntohl(pPacket->flags);
    pPacket->damage = ntohl(pPacket->damage);
    pPacket->shield = ntohl(pPacket->shield);
    pPacket->fuel = ntohl(pPacket->fuel);

    pPacket->etemp = ntohs(pPacket->etemp);
    pPacket->wtemp = ntohs(pPacket->wtemp);
    pPacket->whydead = ntohs(pPacket->whydead);
    pPacket->whodead = ntohs(pPacket->whodead);
}

void status_spacket::FromNetworkByteOrder(BYTE* pb)
{
    status_spacket* pPacket = (status_spacket*)pb;

    pPacket->armsbomb = ntohl(pPacket->armsbomb);
    pPacket->planets = ntohl(pPacket->planets);
    pPacket->kills = ntohl(pPacket->kills);
    pPacket->losses = ntohl(pPacket->losses);
    pPacket->time = ntohl(pPacket->time);
    pPacket->timeprod = ntohl(pPacket->timeprod);
}

void warning_spacket::FromNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 

void planet_spacket::FromNetworkByteOrder(BYTE* pb)
{
    planet_spacket* pPacket = (planet_spacket*)pb;

    pPacket->flags = ntohs(pPacket->flags);
    pPacket->armies = ntohl(pPacket->armies);
}

void queue_spacket::FromNetworkByteOrder(BYTE* pb)
{
    queue_spacket* pPacket = (queue_spacket*)pb;

    pPacket->pos = ntohs(pPacket->pos);        
}

void pickok_spacket::FromNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 

void login_spacket::FromNetworkByteOrder(BYTE* pb)
{
    login_spacket* pPacket = (login_spacket*)pb;

    pPacket->flags = ntohl(pPacket->flags);
}

void plasma_info_spacket::FromNetworkByteOrder(BYTE* pb)
{
    plasma_info_spacket* pPacket = (plasma_info_spacket*)pb;

    pPacket->pnum = ntohs(pPacket->pnum);
}

void plasma_spacket::FromNetworkByteOrder(BYTE* pb)
{
    plasma_spacket* pPacket = (plasma_spacket*)pb;

    pPacket->pnum = ntohs(pPacket->pnum);
    pPacket->x = ntohl(pPacket->x);
    pPacket->y = ntohl(pPacket->y);
}

void pstatus_spacket::FromNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void motd_spacket::FromNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void mask_spacket::FromNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void badversion_spacket::FromNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void reserved_spacket::FromNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 


void ping_spacket::FromNetworkByteOrder(BYTE* pb)
{
    ping_spacket* pPacket = (ping_spacket*)pb;

    pPacket->lag = ntohs(pPacket->lag);
}

void sc_sequence_spacket::FromNetworkByteOrder(BYTE* pb)
{
    sc_sequence_spacket* pPacket = (sc_sequence_spacket*)pb;

    pPacket->sequence = ntohs(pPacket->sequence);
}

void udp_reply_spacket::FromNetworkByteOrder(BYTE* pb)
{
    udp_reply_spacket* pPacket = (udp_reply_spacket*)pb;

    pPacket->port = ntohl(pPacket->port);
}

void sequence_spacket::FromNetworkByteOrder(BYTE* pb)
{
    sequence_spacket* pPacket = (sequence_spacket*)pb;

    pPacket->sequence = ntohs(pPacket->sequence);

}

void planet_loc_spacket::FromNetworkByteOrder(BYTE* pb)
{
    planet_loc_spacket* pPacket = (planet_loc_spacket *) pb;

    pPacket->x = ntohl(pPacket->x);
    pPacket->y = ntohl(pPacket->y);
}

void feature_cpacket::FromNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void rsa_key_spacket::FromNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 

void ship_cap_spacket::FromNetworkByteOrder(BYTE* pb)
{
    ship_cap_spacket* pPacket = (ship_cap_spacket*)pb;

    pPacket->s_type = ntohs(pPacket->s_type);
    pPacket->s_torpspeed = ntohs(pPacket->s_torpspeed);
    pPacket->s_phaserrange = ntohs(pPacket->s_phaserrange);
    pPacket->s_maxspeed = ntohl(pPacket->s_maxspeed);
    pPacket->s_maxfuel = ntohl(pPacket->s_maxfuel);
    pPacket->s_maxshield = ntohl(pPacket->s_maxshield);
    pPacket->s_maxdamage = ntohl(pPacket->s_maxdamage);
    pPacket->s_maxwpntemp = ntohl(pPacket->s_maxwpntemp);
    pPacket->s_maxegntemp = ntohl(pPacket->s_maxegntemp);
    pPacket->s_width = ntohs(pPacket->s_width);
    pPacket->s_height = ntohs(pPacket->s_height);
    pPacket->s_maxarmies = ntohs(pPacket->s_maxarmies);
    pPacket->s_bitmap = ntohs(pPacket->s_bitmap);

}

void shortreply_spacket::FromNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 


struct ClientPacket
{
    int     size;
    void    (*ToNetworkByteOrder) (BYTE *);
};


#define DEFINE_CLIENT_PACKET(x) { sizeof(x), x::ToNetworkByteOrder }
#define DEFINE_SHORT_CLIENT_PACKET() { NULL, NULL }

struct ClientPacket ClientPacketHandlers[] =
{    
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_None,
    DEFINE_CLIENT_PACKET(mesg_cpacket),                     // EClientPacketType_Message,
    DEFINE_CLIENT_PACKET(speed_cpacket),                    // EClientPacketType_SetSpeed,
    DEFINE_CLIENT_PACKET(dir_cpacket),                      // EClientPacketType_SetDirection,
    DEFINE_CLIENT_PACKET(phaser_cpacket),                   // EClientPacketType_FirePhaser,
    DEFINE_CLIENT_PACKET(plasma_cpacket),                   // EClientPacketType_FirePlasma,
    DEFINE_CLIENT_PACKET(torp_cpacket),                     // EClientPacketType_FireTorp,
    DEFINE_CLIENT_PACKET(quit_cpacket),                     // EClientPacketType_Quit,
    DEFINE_CLIENT_PACKET(login_cpacket),                    // EClientPacketType_Login,
    DEFINE_CLIENT_PACKET(outfit_cpacket),                   // EClientPacketType_OutfitToNewShip,
    DEFINE_CLIENT_PACKET(war_cpacket),                      // EClientPacketType_ChangeWarStatus,
    DEFINE_CLIENT_PACKET(practr_cpacket),                   // EClientPacketType_CreatePracticeRobot,
    DEFINE_CLIENT_PACKET(shield_cpacket),                   // EClientPacketType_ToggleShields,
    DEFINE_CLIENT_PACKET(repair_cpacket),                   // EClientPacketType_EnterRepairMode,
    DEFINE_CLIENT_PACKET(orbit_cpacket),                    // EClientPacketType_OrbitPlanetOrStarbase,
    DEFINE_CLIENT_PACKET(planlock_cpacket),                 // EClientPacketType_LockOnToPlanet,
    DEFINE_CLIENT_PACKET(playlock_cpacket),                 // EClientPacketType_LockOnToPlayer,
    DEFINE_CLIENT_PACKET(bomb_cpacket),                     // EClientPacketType_BombPlanet,
    DEFINE_CLIENT_PACKET(beam_cpacket),                     // EClientPacketType_BeamArmies,
    DEFINE_CLIENT_PACKET(cloak_cpacket),                    // EClientPacketType_ToggleCloak,
    DEFINE_CLIENT_PACKET(det_torps_cpacket),                // EClientPacketType_DetEnemyTorps,
    DEFINE_CLIENT_PACKET(det_mytorp_cpacket),               // EClientPacketType_DetMyTorps,
    DEFINE_CLIENT_PACKET(copilot_cpacket),                  // EClientPacketType_CopilotMode,
    DEFINE_CLIENT_PACKET(refit_cpacket),                    // EClientPacketType_Refit,
    DEFINE_CLIENT_PACKET(tractor_cpacket),                  // EClientPacketType_ToggleTractor,
    DEFINE_CLIENT_PACKET(repress_cpacket),                  // EClientPacketType_TogglePressor,
    DEFINE_CLIENT_PACKET(coup_cpacket),                     // EClientPacketType_CoupHomePlanet,
    DEFINE_CLIENT_PACKET(socket_cpacket),                   // EClientPacketType_Socket,
    DEFINE_CLIENT_PACKET(options_cpacket),                  // EClientPacketType_SaveOptions,
    DEFINE_CLIENT_PACKET(bye_cpacket),                      // EClientPacketType_Bye,
    DEFINE_CLIENT_PACKET(dockperm_cpacket),                 // EClientPacketType_SetDockPermission,
    DEFINE_CLIENT_PACKET(updates_cpacket),                  // EClientPacketType_SetUpdateFrequency,
    DEFINE_CLIENT_PACKET(resetstats_cpacket),               // EClientPacketType_ResetStats,
    DEFINE_CLIENT_PACKET(reserved_cpacket),                 // EClientPacketType_Reserved,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Scan,
    DEFINE_CLIENT_PACKET(udp_req_cpacket),                  // EClientPacketType_UDPRequest,
    DEFINE_CLIENT_PACKET(sequence_cpacket),                 // EClientPacketType_SequenceNumber,
    DEFINE_CLIENT_PACKET(rsa_key_cpacket),                  // EClientPacketType_RSAKey,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid38,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid39,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid40,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid41,
    DEFINE_CLIENT_PACKET(ping_cpacket),                     // EClientPacketType_PingResponse,
    DEFINE_CLIENT_PACKET(shortreq_cpacket),                 // EClientPacketType_Short_Request,
    DEFINE_CLIENT_PACKET(threshold_cpacket),                // EClientPacketType_Short_Thrs, // ????
    DEFINE_SHORT_CLIENT_PACKET(),                           // EClientPacketType_Short_Message,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Short_Reserved,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Short_Dummy,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid41,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid42,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid43,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid44,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid45,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid46,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid47,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid48,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid49,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid50,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid51,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid52,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid53,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid54,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid55,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid56,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid57,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid58,
    DEFINE_CLIENT_PACKET(Invalid),                          // EClientPacketType_Invalid59,
    DEFINE_CLIENT_PACKET(feature_cpacket),                  // EClientPacketType_Feature,
};                                                      
  
int CPacket::GetClientPacketLen(EClientPacketType ePacketType)
{
    return ClientPacketHandlers[ePacketType].size;
}

void CPacket::ToNetworkByteOrder(packet_base* pPacket)
{
    ClientPacketHandlers[pPacket->type].ToNetworkByteOrder((BYTE*) pPacket);
}


void torp_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void phaser_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void speed_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void dir_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void shield_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void repair_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void orbit_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void practr_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void bomb_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void beam_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void cloak_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void det_torps_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void copilot_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void outfit_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void login_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void tractor_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void repress_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 

void det_mytorp_cpacket::ToNetworkByteOrder(BYTE* pb)
{
    det_mytorp_cpacket* pPacket = (det_mytorp_cpacket*)pb;

    pPacket->tnum = ntohs(pPacket->tnum);
}

void war_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void refit_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void plasma_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void playlock_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void planlock_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void coup_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void quit_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void mesg_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void socket_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void options_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void bye_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void dockperm_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void updates_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void resetstats_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void reserved_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void udp_req_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void ping_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void sequence_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void feature_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void rsa_key_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void shortreq_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 
void threshold_cpacket::ToNetworkByteOrder(BYTE*) { } // NO REQUIRED IMPLEMENTATION 

